package com.uchedao.seller.config;

import android.content.Context;
import android.content.res.Resources;
import android.os.Environment;
import android.telephony.TelephonyManager;

import com.uchedao.seller.SellerApplication;
import com.uchedao.seller.db.DbHelper;
import com.uchedao.seller.db.User;
import com.uchedao.seller.module.Draft;
import com.uchedao.seller.util.PreferenceUitl;

import java.io.File;

/**
 * 公共信息类
 * 
 * @author "叶晋"
 * 
 */
public class GlobalInfo {
	public static String tempOwner = "13799900000";

	private static final String KEY_VERSION = "version";// 当前应用版本

	public static final String APP_NAME = "sale";

	// 当前的检测
	public static Draft draft;

	// 用户
	public static User user = User.getInstance();

	// 数据库工具
	public static DbHelper dbHelper = new DbHelper(SellerApplication.getContext());

	// Resources
	public static Resources resources = SellerApplication.getContext().getResources();

	// 数据存储
	public static PreferenceUitl dataPu = new PreferenceUitl(SellerApplication.getContext(), "ucdseller", Context.MODE_PRIVATE);

//	// 版本是否有更新
//	public static boolean verUpdate = verUpdate();

	// SD卡图片存储路径
	public static final String PIC_PATH = Environment.getExternalStorageDirectory() + "/ucdseller/";
	static {
		File dir = new File(PIC_PATH);
		if (!dir.exists())
			dir.mkdir();
	}

	// 获得IMEI
	public static final String IMEI = ((TelephonyManager) SellerApplication.getContext().getSystemService(
			SellerApplication.TELEPHONY_SERVICE)).getDeviceId();

	/**
	 * 创建检测
	 * 
	 * @param carPlate
	 * @param vin
	 * @param infoNumber
	 */
	public static void initDraft(String carPlate, String vin, String infoNumber) {
		dbHelper.insertDraf(carPlate, vin, infoNumber);
	}

//	/**
//	 * 版本是否有更新
//	 *
//	 * @author 叶晋
//	 * @修改时间 2012-11-28 上午10:19:45
//	 * @return
//	 */
//	private static boolean verUpdate() {
//		int ver = Util.getAppVersionCode();
//		int oldVer = dataPu.getInt(KEY_VERSION, 0);
//		boolean update = ver > oldVer;
//		if (update) {
//			dataPu.putInt(KEY_VERSION, ver);
//			return true;
//		}
//		return false;
//	}
}
